<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ZH-CN">
<head>
<title>论文设置</title>
<meta http-equiv="X-UA-Compatible" content="IE=9" >
<meta name="keywords" content="吉珠,吉林大学,吉林大学珠海学院,吉林大学珠海学院论文管理">
<meta name="content-type" content="text/html" charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href=".//css/bootstrap.css" type="text/css">
<link rel="stylesheet" href=".//css/flow.css" type="text/css">
<script src=".//js/jquery-2.1.1.js" type="text/javascript"></script>
<script src=".//js/bootstrap.js" type="text/javascript"></script>
<style>
.col-xs-3 {
	padding: 1px;
	height: 710px;
}
.col-xs-9 {
	height: 710px;
}
#xs12 {
	height: 604px;
	width: 313px;
}
</style>
<script type="text/javascript" language="javascript">
function g(o){return document.getElementById(o);}
function hoverli(n){
for(var i=1;i<=28;i++){
{g('tb_'+i).className='';}
g('tb_'+n).className='actived';}
}
function show(id){
var traget=document.getElementById(id);
traget.style.display="block"; 
}

function hide(id){
var traget=document.getElementById(id);
traget.style.display="none"; 
}
var editIndex = undefined;
function onDblClickRow(index){//双击
edit();
		}
function add(){
			if(editIndex!=undefined){
			$('#source').datagrid('endEdit',editIndex);
			}
			$('#source').datagrid('insertRow',{
			index:0,
			row:{
			
			}
			});
			$('#source').datagrid('beginEdit',0);
			editIndex = 0;
			}
function del(){
 			var rows=source.datagrid('getSelections');
 			console.info(rows);
              if(rows.length>0){
            		$.messager.confirm('请确认','您真的要删除选中的项吗',function(r){
            			if(r){
                        	$.ajax({
                        		//url:'${pageContext.request.contextPath}/delete',
                        		url:'${pageContext.request.contextPath}/thesissource-del',
                        		data:"t.thesissource_id="+rows[0].thesissource_id,
                            	type:'post',
                            	dataTye:'json',
                            	success:function(){
                            		$('#source').datagrid('load');
                            		source.datagrid('unselectAll');//取消所有选中的行
                            		$.messager.show({
                            			title:'提示',
                            			msg:'删除成功',
                            		});
                            	} 
                        	 }) 
        				 }
            			else{
                            $.messager.alert('提示','请选择要删除的记录');
                            }
            		})
            	}			
	}			
function edit(index){//编辑
                var rows=source.datagrid('getSelections');
                if(rows.length==1){
                	if(editIndex != undefined){
                        source.datagrid('endEdit',editIndex);
                        }
                	//开启编辑状态
            		if(editIndex == undefined){
                    	var index=source.datagrid('getRowIndex',rows[0]);
               			source.datagrid('beginEdit',index);
               			source.datagrid('unselectAll');//取消所有选中的行
               			editIndex=index;
                		} 
                }
		}
		function accept(){
				console.info("保存的行"+editIndex);
				$('#source').datagrid('endEdit',editIndex);
				
				//$('#source').datagrid('acceptChanges');
			
		}
		function reject(){//撤销
			$('#source').datagrid('rejectChanges').datagrid('unselectAll'); //取消所有选中的行 并回滚
			editIndex = undefined;
		}
		
$(function() {
		source = $("#source").datagrid({
		url : '<%=request.getContextPath()%>/thesissource-show',
		title : '毕业设计重要时间设置',
		resizeable:true,
		onDblClickRow: onDblClickRow,
		pageSize: 10,//每页显示的记录条数，默认为10 
		pageList: [5,10,15],//可以设置每页记录条数的列表 
		pagination : true,
		singleSelect : true,
		sortName : 'thesissource_id',
		sortOrder : 'asc',
		rowStyler: function(index,row){
			return 'height:30px;';
	    },
		fitColumns : true,
		columns : [ [ {
			field : 'thesissource_id',
			title : '',
			sortable : true,
			formatter:function(value,row,index){
						return index+1;
			}
		}, {
			field : 'department_name',
			title : '系名称',
			width : 50,
			
		},{
			field : 'thesissource_name',
			title : '论文课题来源名称',
			width : 50,
			editor: {
					type: 'validatebox',
					options: {
					required:true,
					}
					 }
		},{
			field : 'teacher_name',
			title : '课题添加人姓名',
			width : 20,
		},{
			field : 'thesissource_addtime',
			title : '添加时间',
			width : 40,
		},
		] ],
		 onAfterEdit:function(rowIndex,rowData,changes){
        	var url='';
        	var Data;
        	var updated=source.datagrid('getChanges','updated');
           	var inserted=source.datagrid('getChanges','inserted');
        	console.info(updated);
        	console.info(inserted);
        	if (inserted.length>0){
       			url='${pageContext.request.contextPath}/thesissource-save';
       			Data="t.thesissource_name="+rowData.thesissource_name;
       			
       		
       		}
       		if (updated.length>0){
       			url='${pageContext.request.contextPath}/thesissource-updated';
       			Data="t.thesissource_id="+rowData.thesissource_id+"&t.thesissource_name="+rowData.thesissource_name+"&t.thesissource_department="+rowData.thesissource_department;

       		}
        	$.ajax({
        	url:url,
        	//data:"t.="+rowData.dissType+"&dissName="+rowData.dissName+"&Sin="+rowData.Sin,
        	//data:"rowData="+rowData,
        	data:Data,
        	//data:"t.thesissource_id="+rowData.thesissource_id+"&t.thesissource_name="+rowData.thesissource_name+"&t.thesissource_department="+rowData.thesissource_department,
        	type:'post',
        	dataTye:'json',
        	success:function(data){
        		$('#source').datagrid('load');
        	comboboxData=data;
        	editIndex=undefined;
        	}
      	  }) 
       	 }
		});
});
		function showWhat()
		{
			var collap=document.getElementById('collapseHelp');
			if(collap.style.display=='none')
				collap.style.display='block';
			else
				collap.style.display='none';
		}
</script>
</head>

<body>
<!--全局框架 开始 conteiner-->
<div class="container">
<!--标题头图片-->
<div class="row">
  <div class="body_top"> <img src="img/head.png" align="center" width="1280px"/> </div>
</div>
<!--全局12栅格 规划全局区域图线 开始 row+ col-->
<div class="row">
<jsp:include page="secretary_siderbar.jsp"></jsp:include>
    <!--左侧跳转框架结束--> 
    <!--右侧用户操作模块 占全局9栅格-->
    <div class="col-xs-9"style="border:2px solid #25465d">
      <div class="row">
        <div class="col-xs-4  xs11" style="margin-top:2px; margin-bottom:0px;"> <strong><font size="3">流程管理》论文选题设置 </font></strong> </div>
      </div>
      <div class="col-xs-11  xs11" style="margin-top:2px; margin-bottom:0px;">
        <div class="panel panel-default" style="margin-top:2px; margin-bottom:10px;">
          <div class="panel-heading" align="left"> <a data-toggle="collapse" data-parent="#accordion"  href="#collapseHelp" class="glyphicon glyphicon-chevron-down" onclick="showWhat()"> 操作指南 </a> </div>
          <div id="collapseHelp" class="panel-collapse collapse">
            <div class="panel-body">论文选题设置：
              <ul>
                <li>论文选择过程中，关于论文题目来源可以由教学秘书根据不同单位的实际情况，或根据文理科的不同特点，给予设置。</li>
              </ul>
            </div>
          </div>
        </div>
        <div class="col-xs-12" style="margin-top:5px; margin-bottom:10px;">
          <p><b>论文课题来源设置</b></p>
          <p>所属系名称: ${se[0].department_name}</p>
            
           
         </div>
         <div style="height:auto;">
             <table  id="source" >
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="add()">新增</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="edit()">编辑</a>
<!-- 		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="del()">删除</a>
 -->		
 		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">撤销</a>
             </table>
         	 </div>
          
                    </div>
                  </div>
                </div>
              </div>
              
          </div>
        </div>
      </div>
      <!--修改结束--> 
    </div>
    <!--全局12栅格 规划全局区域图线 结束 row+ col--> 
  </div>
  <div class="row" style="background-color:#25465d"">
    <p  align="center" style="color:white;background-color:#25465d"><strong>用户单位：</strong>吉林大学珠海学院&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>版权所有：</strong>吉林大学珠海学院计算机科学与技术系</p>
  </div>
  <!--全局框架结束 conteiner--> 
</div>
</body>
</html>
